<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>商品信息</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../../../elementUI/index.css">
  <link rel="stylesheet" href="../../../css/index.css">
</head>
<style>
  /* 放大的图片，通过定位将左上角定位到(0,0) */
  .rightImg {
      display: inline-block;
      width: 800px;
      height: 800px;
      position: absolute;
      top: 0;
      left: 0;
  }

  /* 右边的区域图片放大空间 */
  .right {
      margin-left: 500px;
      width: 400px;
      height: 400px;
      border: 1px solid #000;
      position: relative;
      overflow: hidden;
  }

  /* 一个最高层层罩 */
  .maskTop {
      width: 400px;
      height: 400px;
      position: absolute;
      z-index: 1;
      top: 0;
      left: 0;
  }

  /* 层罩，通过定位将左上角定位到(0,0) */
  .top {
      width: 200px;
      height: 200px;
      background-color: rgba(0, 0, 0, 0.4);
      opacity: 0.4;
      position: absolute;
      top: 0;
      left: 0;
  }

  /* 原图的显示 */
  .leftImg {
      width: 400px;
      height: 400px;
      display: inline-block;
  }

  /* 原图的容器 */
  .left {
      width: 400px;
      height: 400px;
      border: 1px solid teal;
      float: left;
      position: relative;
  }
</style>
<body>
  <div id="app" class="minWidth">
    <el-form :inline="true" :form="form">
      <!-- <el-form-item>
        <el-button type="danger">批量下架</el-button>
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" v-if="JSON.parse(sessionStorage.getItem('RoleArr')).some(item=>item=='B0005')" @click="addEnterprise">添加</el-button>
      </el-form-item>
      <el-form-item>
        <el-input  v-model="form.Article_Name" placeholder="请输入内容" @keyup.enter="onSerach"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSerach">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button :type="!imgDelet?'success':'danger'" @click="imgDelet = !imgDelet">{{!imgDelet?'删图':'已激活'}}</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tableData" stripe border
      height="calc(100vh - 140px)" @expand-change="handleChildren" @selection-change="handleSelectionChange"
      style="width: 100%">
      <el-table-column type="expand" width="60">
        <template slot-scope="props">
          <el-table :data="props.row.Children.article_specifications">
            <el-table-column align="center" type="index" width="50" label="序号"></el-table-column>
            <el-table-column align="center" prop="Article_Specifications_SerialNumber" label="规格编号"></el-table-column>
            <el-table-column align="center" prop="Specifications_Name" label="产品规格"></el-table-column>
            <el-table-column align="center" prop="Net_Content" label="净含量"></el-table-column>
            <el-table-column align="center" prop="Unit_Price" label="零售价"></el-table-column>
            <el-table-column align="center" prop="Packing" label="装箱数"></el-table-column>
            <el-table-column align="center" prop="PackingSize" label="装箱尺寸"></el-table-column>
            <el-table-column align="center" prop="OutsidePackingSize" label="外箱尺寸"></el-table-column>
          </el-table>
            <div style="display: flex;align-items: center;margin-top: 10px; position: relative;">
              <h3 style="width: 100px;">商品主图:</h3>
              <el-image @error="errorimg(item)" @click="seeDetail(0,item,props.row)" v-for="(item,i) in props.row.Children.Swiper" :src="DomainIMG + item.Picture_Url" style="width: 100px; height: 100px; border-radius: 9px;border: 1px solid #ccc;margin-right: 10px;cursor: pointer;" />
            </div>
            <div style="display: flex;align-items: center;margin-top: 10px; position: relative;">
              <h3 style="width: 100px;">商品详情图:</h3>
              <el-image @error="errorimg(item)" @click="seeDetail(0,item,props.row)" v-for="(item,i) in props.row.Children.Detail"  :src="DomainIMG + item.Picture_Url" style="width: 100px; height: 100px; border-radius: 9px;border: 1px solid #ccc;margin-right: 10px;cursor: pointer;" />
            </div>
        </template>
      </el-table-column>
      <!-- <el-table-column type="selection" width="60"></el-table-column> -->
      <el-table-column align="center" label="序号" width="50" type="index"></el-table-column>
      <el-table-column align="center" prop="Article_SerialNumber" width="170" label="商品流水号"></el-table-column>
      <el-table-column align="center" label="商品图片" width="125">
        <template v-slot="{row}">
          <div v-if="row.Picture_URL != '/'">
            <el-image @click="seeDetail(1,row)" v-if="row.Picture_URL!=void 0" style="width: 100px; height: 100px; border-radius: 9px;cursor: pointer;" fit="cover"
            @click="handlePreview(row.Article_SerialNumber)" :src="DomainIMG + row.Picture_URL"
            :preview-src-list="Pic"></el-image>
          </div>
          <div v-else>
            暂无封面
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="Article_Name" label="商品名"></el-table-column>
      <el-table-column align="center" prop="Row_Status" label="状态" width="80">
        <template v-slot="{row}">
          <el-tag v-if="row.Row_Status==0" size="small">未下架</el-tag>
          <el-tag v-else type="danger" size="small">已下架</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="Release_Type" label="状态" width="80">
        <template v-slot="{row}">
          <el-tag v-if="row.Release_Type==0" type="danger" size="small">未发布</el-tag>
          <el-tag v-else size="small">已发布</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="Brand_Name" label="品牌"></el-table-column>
      <el-table-column align="center" prop="Category_Name" label="类别"></el-table-column>
      <el-table-column align="center" prop="Series_Name" label="系列"></el-table-column>
      <el-table-column align="center" prop="Item_Name" label="款型"></el-table-column>
      <el-table-column align="center" prop="Unit_Price" label="吊牌价"></el-table-column>
      <el-table-column align="center" prop="Enterprise_Name" label="所属企业" width="250"></el-table-column>
      <el-table-column align="center" label="操作" width="200">
        <template v-slot="{row}">
          <div v-if="row.Enterprise_Info_SerialNumber==Enterprise_Info_SerialNumber">
            <el-button v-if="JSON.parse(sessionStorage.getItem('RoleArr')).some(item=>item=='B0006')" type="primary" size="small" @click="showMember(row.Article_SerialNumber)">编辑</el-button>
            <el-button type="warning" size="small" v-show="row.Row_Status=='0'"
              @click="deletMember(row)">下架</el-button>
            <el-button type="success" size="small" v-show="row.Row_Status=='1'"
              @click="deletMember(row)">上架</el-button>
            <el-button type="info" size="small"
              v-show="row.Release_Type=='1'"
              @click="stateMember(row,0)" :loading="row.loading">隐藏</el-button>
            <el-button type="success" size="small"
              v-show="row.Release_Type=='0'"
              @click="stateMember(row,0)" :loading="row.loading">发布</el-button>
            <el-button  v-if="JSON.parse(sessionStorage.getItem('RoleArr')).some(item=>item=='B0007')" type="danger" size="small" style="margin-top: 10px;"
              @click="omitMember(row.Article_SerialNumber)">删除</el-button>
          </div>
          <div v-else>
            <el-button type="success" size="small" v-show="row.Release_Type=='1'"
              @click="stateMember(row,1)" :loading="loading">购买</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-dialog title="多层价格" :visible.sync="dialogFormVisible">
      <div class="operation">
        <el-button type="primary" size="small" @click="add_article_specifications">新增</el-button>
        <el-button type="danger" size="small" @click="remove_article_specifications">删除</el-button>
      </div>
      <el-descriptions :column="3" border size="small" v-for="(item,index) in Multistage" :key="index">
        <el-descriptions-item label="价格">
          <el-input v-model.trim="item.Unit_Price" placeholder="请输入零售价"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="数量">
          <el-input v-model.trim="item.Quantity" placeholder="请输入数量"></el-input>
        </el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="UploadPrice">确 定</el-button>
      </div>
    </el-dialog> -->
    <el-pagination background v-show="total > 0" @size-change="handleSizeChange" @current-change="handleCurrentChange"
      :current-page="form.page" :page-sizes="[10, 20, 30, 50]" :page-size="form.limit"
      layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
    <div @click.stop="offMask" v-show="mask" style="position: absolute;top: 0;right: 0;bottom: 0;left: 0;background-color: rgba(0, 0, 0, 0.4);width: 100vw;height: 100vh;z-index: 999;cursor: pointer;">
      <div style="position: absolute;top: 0;right: 0;bottom: 0;left: 0;margin: auto;width: 80%;height: 80%;">
        <div class="left">
            <img class="leftImg" :src="maskURL" alt="" />
            <!-- 鼠标层罩 -->
            <div v-show="topShow" class="top" :style="topStyle"></div>
            <!-- 最顶层覆盖了整个原图空间的透明层罩 -->
            <div class="maskTop" @mouseenter="enterHandler" @mousemove="moveHandler" @mouseout="outHandler">
            </div>
        </div>
        <div v-show="rShow" class="right">
            <img :style="r_img" class="rightImg" :src="maskURL" alt="" />
        </div>
    </div>
    </div>
  </div>
  <script type="text/javascript" src="../../../js/jquery-3.6.0.min.js"></script>
  <script type="text/javascript" src="../../../js/jquery.cookie.js"></script>
  <script type="text/javascript" src="../../../js/vue.min.js"></script>
  <script type="text/javascript" src="../../../elementUI/index.js"></script>
  <script type="text/javascript" src="../../../js/utils.js"></script>
  <script type="text/javascript" src="./js/Goods.js"></script>
  <script type="text/javascript">
    window.onload = function(){
      var box = document.getElementsByClassName("box")[0];
      console.log(box);
      var small = box.children[0];
      var big = box.children[1];
      var bigImg = big.children[0];
      var mask = small.children[1];

      //big和mask在鼠标移入small时显示，移出时隐藏
      small.onmouseenter = function(){
        big.style.display = "block";
        mask.style.display = "block";
      };
      small.onmouseleave = function(){
        big.style.display = "none";
        mask.style.display = "none";
      };

      small.onmousemove = function(event){
        event = event || window.event;
        //mask跟随鼠标移动，且不会超出small范围
        //x作为mask的left值，y作mask的top值。
        var pagex = event.pageX || scroll().left + event.clientX;
        var pagey = event.pageY || scroll().top + event.clientY;

        //减去mask宽高的一半，让鼠标在mask的中间
        var x = pagex - box.offsetLeft - mask.offsetWidth/2;
        var y = pagey - box.offsetTop - mask.offsetHeight/2;

        //不让mask超出small
        if(x < 0){
          x=0;
        }
        if(x > small.offsetWidth - mask.offsetWidth){
          x = small.offsetWidth - mask.offsetWidth;
        }
        if(y < 0){
          y=0;
        }
        if(y > small.offsetHeight - mask.offsetHeight){
          y = small.offsetHeight - mask.offsetHeight;
        }

        mask.style.left = x + "px";
        mask.style.top = y + "px";

        //bigImg随着mask的移动移动
        //比例 = 大图移动的距离/mask移动的距离 = 大图/小图
        var scale = bigImg.offsetWidth / small.offsetWidth;

        bigImg.style.marginLeft = -scale * x +"px";
        bigImg.style.marginTop = -scale * y +"px";
      }
    };
  </script>
</body>

</html>